package com.wxws.sms;

public class VipControl {
	Vip[] vn = new Vip[100];

	public void add(Vip v) {
		for (int i = 0; i < vn.length; i++) {
			if (vn[i] == null) {
				vn[i] = v;
				return;
			}
		}
	}

	public void print() {
		for (int i = 0; i < vn.length; i++) {
			if (vn[i] != null) {
				vn[i].show();
			}
		}
	}

	public boolean search(int vipNum) {
		for (int i = 0; i < vn.length; i++) {
			if (vn[i] != null && vn[i].vipNum == vipNum) {
				return true;
			}
		}
		return false;
	}

	public Vip delete(int VipNum) {
		for (int i = 0; i < vn.length; i++) {
			if (vn[i] != null && VipNum == vn[i].vipNum) {
				Vip vv = vn[i];
				vn[i] = null;
				for (int j = i; j < vn.length - 1; j++) {
					Vip temp = vn[j];
					vn[j] = vn[j + 1];
					vn[i + 1] = temp;
				}
				return vv;
			}
		}
		return null;
	}
}
